﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BKH.BLL;

namespace BKH.MyUserControl.UCHienThi
{
    public partial class UCTimKiemBN : UserControl
    {
        String ID_Co;
        public UCTimKiemBN()
        {
            InitializeComponent();
        }
        BenhNhanBUO bnbuo = new BenhNhanBUO();
        private void btnTim_Click(object sender, EventArgs e)
        {
<<<<<<< .mine

=======
<<<<<<< .mine

=======
<<<<<<< .mine
>>>>>>> .r20
>>>>>>> .r21
            //Tim kiem theo ten benh nhan
            if (radioButton1.Checked==true)
            {
                
                String hoten = txtTimTheoTen.Text.Trim();                
                String[] s = hoten.Split();
                String ten="";
                for (int i = 1; i < s.Length; i++)
                {
                    ten += " "+s[i];
                }                
                dataGridView1.DataSource=bnbuo.Search(ten.Trim());
                
            }
            //tim kiem theo ma benh nhan
            if (radioButton2.Checked==true)
            {
                
                dataGridView1.DataSource = bnbuo.Search(int.Parse(txtTimTheoMaBN.Text));
            }

            //Tim kiem theo CMND
            if (radioButton3.Checked==true)
            {
                
                dataGridView1.DataSource = bnbuo.SearchByCMND(txtTimTheoCMND.Text);
            }
<<<<<<< .mine

           

=======
<<<<<<< .mine

           

=======
=======
           
>>>>>>> .r19
>>>>>>> .r20
>>>>>>> .r21
        }
<<<<<<< .mine

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = false;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = false;
            txtTimTheoTen.ReadOnly = true;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = false;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = true;
        }

        private void lịchSửKhámToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucLichSuKham ls = new ucLichSuKham(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, ls, "gbHienThi");
        }
        /// <summary>
        /// Lấy id Bệnh nhân
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);


                    // Only RowHeader and Cells (which make up a row) should fire a menu
                    if (hit.Type == DataGridViewHitTestType.RowHeader
                        || hit.Type == DataGridViewHitTestType.Cell
                        && hit.RowIndex >= 0)
                    {
                        // Notice how I assign the menu to the dataGridView below...

                        dataGridView1.ClearSelection();
                        dataGridView1.Rows[hit.RowIndex].Selected = true;
                        dataGridView1.ContextMenuStrip = contextMenuStrip1;
                        dataGridView1.ContextMenuStrip.Show(this.dataGridView1, new Point(e.X, e.Y));


                        ID_Co = dataGridView1.Rows[hit.RowIndex].Cells[0].Value.ToString();

                    }
                    // and then I remove the menu here...
                    // This is because after we assign it to the dataGridView
                    // it allows you to right-click anywhere on the control to
                    // get a menu.  Try removing this line and expirement.
                    dataGridView1.ContextMenuStrip = null;

                }
            }
            catch 
            {
                contextMenuStrip1.Visible = false;

            }
        }

        private void thôngTinNgườiNhàToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucThongTinNguoiNha info = new ucThongTinNguoiNha(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, info, "gbHienThi");
        }
=======
<<<<<<< .mine

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = false;
            txtTimTheoCMND.Text = "";
            txtTimTheoMaBN.Text = "";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = false;
            txtTimTheoTen.ReadOnly = true;
            txtTimTheoCMND.Text = "";
            txtTimTheoTen.Text = "";
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = false;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = true;
            txtTimTheoMaBN.Text = "";
            txtTimTheoTen.Text = "";
        }

        private void lịchSửKhámToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucLichSuKham ls = new ucLichSuKham(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, ls, "gbHienThi");
        }
        /// <summary>
        /// Lấy id Bệnh nhân
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);


                    // Only RowHeader and Cells (which make up a row) should fire a menu
                    if (hit.Type == DataGridViewHitTestType.RowHeader
                        || hit.Type == DataGridViewHitTestType.Cell
                        && hit.RowIndex >= 0)
                    {
                        // Notice how I assign the menu to the dataGridView below...

                        dataGridView1.ClearSelection();
                        dataGridView1.Rows[hit.RowIndex].Selected = true;
                        dataGridView1.ContextMenuStrip = contextMenuStrip1;
                        dataGridView1.ContextMenuStrip.Show(this.dataGridView1, new Point(e.X, e.Y));


                        ID_Co = dataGridView1.Rows[hit.RowIndex].Cells[0].Value.ToString();

                    }
                    // and then I remove the menu here...
                    // This is because after we assign it to the dataGridView
                    // it allows you to right-click anywhere on the control to
                    // get a menu.  Try removing this line and expirement.
                    dataGridView1.ContextMenuStrip = null;

                }
            }
            catch 
            {
                contextMenuStrip1.Visible = false;

            }
        }

        private void thôngTinNgườiNhàToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucThongTinNguoiNha info = new ucThongTinNguoiNha(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, info, "gbHienThi");
        }
=======

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = false;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = true;
            txtTimTheoMaBN.ReadOnly = false;
            txtTimTheoTen.ReadOnly = true;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            txtTimTheoCMND.ReadOnly = false;
            txtTimTheoMaBN.ReadOnly = true;
            txtTimTheoTen.ReadOnly = true;
        }

        private void lịchSửKhámToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucLichSuKham ls = new ucLichSuKham(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, ls, "gbHienThi");
        }
        /// <summary>
        /// Lấy id Bệnh nhân
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);


                    // Only RowHeader and Cells (which make up a row) should fire a menu
                    if (hit.Type == DataGridViewHitTestType.RowHeader
                        || hit.Type == DataGridViewHitTestType.Cell
                        && hit.RowIndex >= 0)
                    {
                        // Notice how I assign the menu to the dataGridView below...

                        dataGridView1.ClearSelection();
                        dataGridView1.Rows[hit.RowIndex].Selected = true;
                        dataGridView1.ContextMenuStrip = contextMenuStrip1;
                        dataGridView1.ContextMenuStrip.Show(this.dataGridView1, new Point(e.X, e.Y));


                        ID_Co = dataGridView1.Rows[hit.RowIndex].Cells[0].Value.ToString();

                    }
                    // and then I remove the menu here...
                    // This is because after we assign it to the dataGridView
                    // it allows you to right-click anywhere on the control to
                    // get a menu.  Try removing this line and expirement.
                    dataGridView1.ContextMenuStrip = null;

                }
            }
            catch 
            {
                contextMenuStrip1.Visible = false;

            }
        }

        private void thôngTinNgườiNhàToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ucThongTinNguoiNha info = new ucThongTinNguoiNha(int.Parse(ID_Co));
            ControlAcess.ShowConTrol(this.ParentForm, info, "gbHienThi");
        }
>>>>>>> .r20
>>>>>>> .r21
    }
}
